<!-- templates/product_sell.html -->
{% extends 'base.html' %}
{% load static %}
{% block content %}

<style>
    .card-product {
        transition: transform 0.2s ease;
    }

    .card-product:hover {
        transform: translateY(-5px);
    }

    .product-image {
        max-height: 200px;
        object-fit: cover;
        width: 100%;
        border-radius: 8px;
    }
</style>

<div class="container py-5">
    <h3 class="mb-4 text-center">📦 农产品上架管理</h3>

    {% if products %}
    <div class="row g-4">
        {% for product in products %}
        <div class="col-md-4">
            <div class="card card-product shadow-sm h-100">
                <div class="card-body">
                    {% if product.product_image %}
                    <img src="{{ product.product_image.url }}" alt="产品图片" class="product-image mb-3">
                    {% else %}
                    <div class="text-center text-muted mb-3">无图片</div>
                    {% endif %}

                    <p><strong>原材料来源：</strong>{{ product.raw_material_source|truncatechars:50 }}</p>
                    <p><strong>生产过程：</strong>{{ product.production_process|truncatechars:50 }}</p>
                    <p><strong>检验批次：</strong>{{ product.inspection_batch }}</p>

                    <hr>
                    <div class="d-grid">
                        <a href="{% url 'sell_product' product.id %}" class="btn btn-primary">上架此商品</a>
                    </div>
                </div>
            </div>
        </div>
        {% endfor %}
    </div>
    {% else %}
    <div class="alert alert-info text-center mt-4">
        暂无未上架的商品，请先<a href="{% url 'input_data' %}">录入农产品信息</a>。
    </div>
    {% endif %}
</div>

{% endblock %}
